package de.hub.sar.itsec.sslfetcher.hosts;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ExampleHostProvider implements IHostsProvider {
	private final List<Host> hosts;
	
	public ExampleHostProvider() {
		this.hosts = new ArrayList<Host>(100);
		
		// add some static hardcoded hosts
		this.hosts.add(new Host("google.de", "www.google.de", 443));
		this.hosts.add(new Host("banking.sparda.de", "banking.sparda.de", 443));
		this.hosts.add(new Host("sparkasse.de", "sparkasse.de", 443));
		this.hosts.add(new Host("hu-berlin.de", "informatik.hu-berlin.de", 443));
		this.hosts.add(new Host("www.postbank.de", "www.postbank.de", 443));
		this.hosts.add(new Host("151.189.21.100", "www.arcor.de", 443));
		this.hosts.add(new Host("23.32.143.186", "www.paypal.de", 443));
		this.hosts.add(new Host("193.41.133.1", "www.comdirect.de", 443));
	}

	@Override
	public Iterator<Host> iterator() {
		return new HostsIterator();
	}
	
	private class HostsIterator implements Iterator<Host> {
		int index;
		
		private HostsIterator() {
			this.index = 0;
		}
		
		@Override
		public boolean hasNext() {
			return this.index < hosts.size();
		}

		@Override
		public Host next() {
			return hosts.get(this.index++);
		}

		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
	}
}
